#define _CRT_SECURE_NO_WARNINGS 1

#include<stdio.h>

void rotate(int* nums, int numsSize, int k) {

    int n = numsSize;
    k %= n;

    int tmp = 0;

    int left = n - k;
    int right = n - 1;

    while (left < right)
    {

        tmp = nums[right];
        nums[right] = nums[left];
        nums[left] = tmp;
        left++;
        right--;

    }
    left = 0;
    right = n - k - 1;


    while (left < right)
    {

        tmp = nums[right];
        nums[right] = nums[left];
        nums[left] = tmp;
        left++;
        right--;

    }


    left = 0;
    right = n - 1;

    while (left < right)
    {

        tmp = nums[right];
        nums[right] = nums[left];
        nums[left] = tmp;
        left++;
        right--;

    }



}


int main()
{
    int nums[7] = { 1,2,3,4,5,6,7 };
    int numsSize = sizeof(nums) / sizeof(nums[0]);

    int k = 3;

    rotate(nums, numsSize, k);

    int n = 0;

    for (int i = 0; i < numsSize; i++)
    {
        printf("%d ", nums[i]);
    }


    return 0;

}


